package contract.jvm;

/**
 * 局部变量
 */
public class LocalVariable {

    /**
     * 局部变量数组
     */
    private final Object[] localVariables;

    /**
     * 局部变量构造方法
     */
    public LocalVariable(int maxLocals, Object[] methodArgs) {
        this.localVariables = new Object[maxLocals];
        if (methodArgs != null) {
            System.arraycopy(methodArgs, 0, this.localVariables, 0, methodArgs.length);
        }
    }

    /**
     * 获取局部变量的值
     */
    public Object get(int index) {
        return this.localVariables[index];
    }

    /**
     * 设置局部变量的值
     */
    public void set(int index, Object value) {
        this.localVariables[index] = value;
    }

}
